<?php
declare (strict_types=1);

namespace app\api\controller;

use think\response\Json;
use app\common\model\Agreement as AgreementModel;

/**
 * 协议条款
 * Class help
 * @package app\store\controller\wxapp
 */
class Agreement extends Controller
{
    /**
     * 获取详情记录
     * @return Json
     * @throws \think\db\exception\DbException
     */
    public function detail(string $name): Json
    {
        $model = new AgreementModel;
        try {
            $data = $model->detailbyname($name)->toArray();
            $data['content'] = picReplace($data['content'] ?? '');
        } catch (\Throwable $th) {
            $data = [
                'title' => '',
                'content' => ''
            ];
        }
        
        return $this->renderSuccess($data);
    }
}
